package cn.edu.stu.syllabus.datas;

import java.util.HashMap;
import java.util.Map;

import cn.edu.stu.syllabus.R;
import cn.edu.stu.syllabus.application.SyllabusApplication;

/**
 * Created by daidaijie on 2017/3/27.
 */

public class LibrarySearchCondition {

    public String[] mQueryWays;

    public Map<String, String> mQueryWayStringMap;

    public String[] mSortWays;

    public Map<String, String> mSortWaysStringMap;

    public String[] mOrderWays;

    public Map<String, String> mOrderWaysStringMap;

    private LibrarySearchCondition() {
        mQueryWays = getStringArrays(R.array.query_lib_string);
        mQueryWayStringMap = getL2LMap(mQueryWays, getStringArrays(R.array.query_lib));

        mSortWays = getStringArrays(R.array.query_lib_sf_string);
        mSortWaysStringMap = getL2LMap(mSortWays, getStringArrays(R.array.query_lib_sf));

        mOrderWays = getStringArrays(R.array.query_lib_ob_string);
        mOrderWaysStringMap = getL2LMap(mOrderWays, getStringArrays(R.array.query_lib_ob));
    }

    private String[] getStringArrays(int id) {
        return SyllabusApplication.getContext().getResources().getStringArray(id);
    }


    private Map<String, String> getL2LMap(String[] keys, String[] values) {
        Map<String, String> map = new HashMap<>();
        for (int i = 0; i < keys.length; i++) {
            map.put(keys[i], values[i]);
        }
        return map;
    }

    private static class LibrarySearchConditionHolder {
        private static LibrarySearchCondition sLibrarySearchCondition = new LibrarySearchCondition();
    }

    public static LibrarySearchCondition getInstance() {
        return LibrarySearchConditionHolder.sLibrarySearchCondition;
    }
}
